﻿using UnityEngine;
using System.Collections;

public class Score{
	
	public static int donvi;
	public static int chuc;
	public static int vuottrung=0;
	public static int lose =0;
	public static int diem =0;
	GameObject Diem;
	GameObject Chuc;
	
	public void InitScore(){
		donvi = 0;
		chuc = 0;
		vuottrung = 0;
		lose = 0;
		diem = 0;
		Diem.transform.position = new Vector3(0,240,-1);
		Diem.renderer.material.mainTextureScale = new Vector2 (0.1f, 1);
		Diem.renderer.material.mainTextureOffset = new Vector2 (0, 0);
		Chuc.transform.position = new Vector3(0,-550,-1);
		Chuc.renderer.material.mainTextureScale = new Vector2 (0.1f, 1);
		Chuc.renderer.material.mainTextureOffset = new Vector2 (0, 0);
	}
	


	public void LoadScore(){
		Diem = Graphic.Draw ("Score", new Vector2 (75,85), "IMG/number");
		Diem.transform.position = new Vector3(65,-550,-1);
		Diem.renderer.material.mainTextureScale = new Vector2 (0.1f, 1);
		
		Chuc = Graphic.Draw ("Chuc", new Vector2 (75,85), "IMG/number");
		Chuc.transform.position = new Vector3(0,-550,-1);
		Chuc.renderer.material.mainTextureScale = new Vector2 (0.1f, 1);
		
	}


	public void UpdateScore(){
		float dv = Diem.renderer.material.mainTextureOffset.x;
		float c = Chuc.renderer.material.mainTextureOffset.x;
		dv = donvi/10f;
		dv = dv % 1;
		Diem.renderer.material.mainTextureOffset = new Vector2 (dv, 0);
		if (chuc != 0) {
			Diem.transform.position = new Vector3(65,240,-1);
			Chuc.transform.position = new Vector3(0,240,-1);
			c = chuc/10f;
			c = c % 1;
			Chuc.renderer.material.mainTextureOffset = new Vector2 (c, 0);
		}
	}
}
